package com.huluobo.mvvm.db.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.huluobo.mvvm.db.eneity.UserInfo;

import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Observable;

/**
 * Completable 可观测对象,类似于ApiService中的Observable 是一个可观测的对象,可以用于切换线程,也就是异步操作
 * Flowable 也是一个可观测对象
 * Created by LC on 2023/9/16.
 */
@Dao
public interface UserInfoDao {

    //插入
    //onConflict 设置冲突策略,(REPLACE -替换,ABORT - 回滚,IGNORE-忽略)
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Completable insertUserInfo(UserInfo userInfo);

    //删除
    @Delete
    Completable deleteUserInfo(UserInfo userInfo);

    //更新
    @Update
    Completable updateUserInfo(UserInfo userInfo);

    @Query("select * from user_info where username =:username")
    Observable<UserInfo> queryUserInfo(String username);

}
